home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac Magazin/MacEasy 32
/
Mac Magazin and MacEasy Magazine CD - Issue 32.iso
/
Multimedia
/
PlayerPRO 4.5.5 Dev.Kit
/
Plug-Ins
/
Sound Filters Plugs
/
Smooth.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-10-08
|
2KB
|
85 lines
/* Smooth */
/* v 0.2 */
/* 1995 by Liane */
// Usage:
// Works like a low pass filter, removing high
// harmonics generated by a low sampling rate.
// Works on the selected part or all the waveform
// if there is no selection.
// Not very accurate, but pretty fast to write !!!
#include "MAD.h"
#include "PPPlug.h"
#if defined(powerc) || defined(__powerc)
enum {
PlayerPROPlug = kCStackBased
| RESULT_SIZE(SIZE_CODE( sizeof(OSErr)))
| STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof( sData*)))
| STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof( long)))
| STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof( long)))
| STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof( PPInfoPlug*)))
};
ProcInfoType __procinfo = PlayerPROPlug;
#else
#include <A4Stuff.h>
#endif
OSErr main( sData *theData,
long SelectionStart,
long SelectionEnd,
PPInfoPlug *thePPInfoPlug)
{
long i, length, temp, prevtemp, nexttemp, work;
if (SelectionStart == SelectionEnd) {
SelectionStart = 0;
SelectionEnd = theData->size;
}
length = SelectionEnd - SelectionStart - 1;
switch( theData->amp)
{
case 8:
{
Ptr SamplePtr = (theData->data) + SelectionStart;
prevtemp = *SamplePtr++;
temp = *SamplePtr++;
for( i = 1; i < length; i++)
{
nexttemp = *SamplePtr--;
work = ((prevtemp + nexttemp) + (temp * 6)) >> 3;
*SamplePtr++ = work;
prevtemp = temp;
temp = nexttemp;
SamplePtr++;
}
} break;
case 16:
{
short *SamplePtr = (short*) theData->data + (SelectionStart / 2);
prevtemp = *SamplePtr++;
temp = *SamplePtr++;
for( i = 1; i < length / 2; i++)
{
nexttemp = *SamplePtr--;
work = ((prevtemp + nexttemp) + (temp * 6)) >> 3;
*SamplePtr++ = work;
prevtemp = temp;
temp = nexttemp;
SamplePtr++;
}
} break;
}
return noErr;
}